package rattlesnake.callback.rest;

import com.sun.corba.se.spi.ior.ObjectKey;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rattlesnake.callback.core.cache.Cache;
import rattlesnake.callback.core.cache.CacheManager;
import rattlesnake.callback.core.cache.Element;
import rattlesnake.callback.manager.CallbackEnvConfig;
import rattlesnake.callback.util.MJsonBuilder;

import java.lang.annotation.Retention;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @Package: rattlesnake.callback.rest
 * @Description: 系统缓存信息
 * @author: liuxin
 * @date: 17/4/10 下午4:46
 */
@RestController
public class SystemController {
//    @Autowired
//    CacheManager cacheManager;
    @Autowired
    CallbackEnvConfig callbackEnvConfig;

    @RequestMapping(value = "/cache-info")
    public String cacheInfo() {
//        Map<Object, Object> map = null;
//        map = new HashedMap();
//        String[] names = cacheManager.getCacheNames();
//        map.put("当前总缓存数量", names.length);
//        map.put("当前缓存集合", names);
//        Cache ce = cacheManager.getCache("fft");
//        Set<Object> sets = ce.getAll().keySet();
//        Iterator<Object> iterator = sets.iterator();
//        while (iterator.hasNext()) {
//            String key = (String) iterator.next();
//            Element element = ce.get(key);
//            System.out.println(element.getKey() + "" + element.getValue());
//        }
        return new MJsonBuilder().setPrettyPrint().toJson("");
    }
    @RequestMapping("testss")
    public String info(){
        System.out.println(callbackEnvConfig.getNum());
        return callbackEnvConfig.getNum();
    }
}
